using com.youzu.warh.protocol;
using CustomDataStruct;
using ProtoBuf.Serializers;

namespace battle
{
    public class SiegeFightInfoDecorator: ICustomProtoSerializer
    {
        public void SetValue(object target, object value, int fieldNumber)
        {
            SiegeFightInfo data = target as SiegeFightInfo;
            if (data == null)
            {
                return;
            }

            switch (fieldNumber)
            {
                case 1:
                    data.coordinate = (Coordinate) value;
                    break;
                case 2:
                    data.elements.Add((EffectElement)value);
                    break; 
                case 3:
                    data.target = (MapUnit) value;
                    break;
                case 4:
                    data.mountUnits.Add((BattleMountUnit)value);
                    break;
                case 5:
                    data.plunderRes.Add((PlunderResResult)value);
                    break;
            }
        }

        public object GetValue(object target, int fieldNumber)
        {
            SiegeFightInfo data = target as SiegeFightInfo;
            if (data == null)
            {
                return null;
            }

            switch (fieldNumber)
            {
                case 1:
                    return data.coordinate;
                case 2:
                    return data.elements;
                case 3:
                    return data.target;
                case 4:
                    return data.mountUnits;
                case 5:
                    return data.plunderRes;
            }

            return null;
        }
    }
}